{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1459
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	a:int64;
 
function inttoroman(num:int64):string;
const Nvals = 13; vals: array[1..Nvals] of word = (1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000); roms: array[1..Nvals] of string[2] = ('I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M');
var b: 1..Nvals;
begin
result := '';
b := Nvals;
while num > 0 do begin
  while vals[b]>num do dec(b);
  dec(num,vals[b]);
  result:=result+roms[b]
end;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(A);
write(inttoroman(a));
end.